package com.wsjzzcbq.qianyuan.sys.controller;

import com.wsjzzcbq.qianyuan.common.bean.PageBean;
import com.wsjzzcbq.qianyuan.common.bean.R;
import com.wsjzzcbq.qianyuan.sys.bean.SysRole;
import com.wsjzzcbq.qianyuan.sys.param.AddSysRoleParam;
import com.wsjzzcbq.qianyuan.sys.param.FindSysRoleListParam;
import com.wsjzzcbq.qianyuan.sys.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;

/**
 * RoleController
 *
 * @author wsjz
 * @date 2022/03/11
 */
@RequestMapping("/sys/role")
@RestController
public class SysRoleController {

    @Autowired
    private SysRoleService sysRoleService;

    @PostMapping(value = "/findList")
    public R<PageBean<SysRole>> findList(@RequestBody FindSysRoleListParam param) {
        return sysRoleService.findList(param);
    }

    @GetMapping("/findAllMenuList")
    public R<?> findAllMenuList() {
        return sysRoleService.findAllMenuList();
    }

    @PostMapping("/addOrUpdate")
    public R<?> addSysRole(@RequestBody @Valid AddSysRoleParam param) {
        return sysRoleService.addOrUpdateSysRole(param);
    }

    @GetMapping("/findSysRoleById")
    public R<?> findSysRoleById(String id) {
        return sysRoleService.findSysRoleById(id);
    }

    @DeleteMapping("/deleteSysRoleById")
    public R<?> deleteSysRoleById(String id) {
        return sysRoleService.deleteSysRoleById(id);
    }

    @GetMapping("/findRoles")
    public R<?> findRoles() {
        return sysRoleService.findRoles();
    }
}
